/**
 * User: dizemding
 * Time: 11-7-20 下午5:21
 */
function formatFloat(src, pos) {
	return Math.round(src * Math.pow(10, pos)) / Math.pow(10, pos);
}

function doRating(rate) {
	$("#rating_num").val(rate)
	$('.ratings_star').attr("class", "ratings_star ratings_star_off")
	for (var i = 0; i < rate; ++i) {
		$('.ratings_star:eq(' + i + ')').attr("class", "ratings_star ratings_star_on")
	}
}


$(function() {
	$("#dialog:ui-dialog").dialog("destroy");

	$("#dialog-comment").dialog({
		autoOpen: false,
		height: 375,
		width: 510,
		modal: true,
		show:"clip",
		hide:"blind",
		buttons: {
			"确定": function() {
				$('#form-reply :submit').click();
				$(this).dialog('close');
				alert("评论成功")
			},
			"关闭": function() {
				$(this).dialog('close');
			}
		}
	});


	var $sidebar1 = $("#inner_side"), offset1 = $sidebar1.offset();
	$(window).scroll(function() {
		if ($(window).scrollTop() > offset1.top) {
			$sidebar1.stop().animate({
				marginTop: $(window).scrollTop() - offset1.top + 10
			});

		} else {
			$sidebar1.stop().animate({
				marginTop: 0
			});
		}
	});

	var $sidebar2 = $("#sidebar"), offset2 = $sidebar2.offset();
	$(window).scroll(function() {
		if ($(window).scrollTop() > offset2.top) {
			$sidebar2.stop().animate({
				marginTop: $(window).scrollTop() - offset2.top + 10
			});

		} else {
			$sidebar2.stop().animate({
				marginTop: 0
			});
		}
	});


});